package com.shk.service.imp;


import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.shk.dao.MenuDao;
import com.shk.entity.PageResult;
import com.shk.entity.QueryPageBean;
import com.shk.pojo.Menu;
import com.shk.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = MenuService.class)
@Transactional
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuDao menuDao;


    @Override
    public void add(Menu menu) {
        menuDao.add(menu);
    }

    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
      Page<Menu> page =  menuDao.findPage(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void delete(Integer id) {
        menuDao.delete(id);
    }

    @Override
    public Menu findById(Integer id) {

      Menu menu = menuDao.findById(id);
        return menu;
    }

    @Override
    public void update(Menu menu) {
        menuDao.update(menu);
    }

    @Override
    public List<Menu> findAll() {

       List<Menu> data =  menuDao.findAll();
       return data;
    }


}
